import { Module, ValidationPipe } from '@nestjs/common';
import { DbModule } from './database/db.module';
import { SystemModule } from './modules/system/system.module';
import { APP_GUARD, APP_PIPE } from '@nestjs/core';
import { AuthGuard } from './guards/auth.guard';
import { CoreModule } from './modules/core/core.module';
import { ConfigModule } from '@nestjs/config';
import { WsGateway } from './modules/socket/ws.gateway';

@Module({
  imports: [
    DbModule,
    SystemModule,
    CoreModule,
    // 加载 .env 文件
    ConfigModule.forRoot({ isGlobal: true, cache: true }),
  ],
  controllers: [],
  providers: [
    WsGateway,
    {
      provide: APP_GUARD,
      useClass: AuthGuard,
    },
    {
      provide: APP_PIPE,
      useClass: ValidationPipe,
    }
  ],
})
export class AppModule {}
